﻿using Darius.API.Application.Commands.Defective;
using IMES.Common.Dtos;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Darius.API.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class DefectiveController : ControllerBase
    {
        private readonly IMediator Mediator;

        public DefectiveController(IMediator mediator)
        {
            Mediator = mediator;
        }
        /// <summary>
        /// 不良品项分布
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<Result> GetDefectiveProducts(DefectiveSearchCommand cmd)
        {
            return await Mediator.Send(cmd);
        }
        /// <summary>
        /// 不良品项统计
        /// </summary>
        /// <param name="cmd"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Result> DefectiveSum()
        {
            return await Mediator.Send(new DefectiveSumCommand());
        }
    }
}
